import 'package:flutter/material.dart';
import 'package:x3_base_core/x3_base_core.dart';
import 'package:x3_component_core/x3_component_core.dart';

class BusinessRetailsOrderStyleItem extends StatelessWidget {
  BusinessRetailsOrderStyleItem({Key key, @required this.styleItem}) : super(key: key);

  final dynamic styleItem;

  @override
  Widget build(BuildContext context) {
    return _buildStyleItem();
  }

  Widget _buildStyleItem() {
    String clothingImg = BaseUtils.getKeyData(this.styleItem, 'clothingImg').toString();
    return Container(
      padding: EdgeInsets.symmetric(vertical: 12.0),
      child: Row(
        crossAxisAlignment: CrossAxisAlignment.start,
        children: [
          BaseImageComponent(
            imageUrl: clothingImg,
            width: 80,
            height: 80,
            circular: 4,
          ),
          SizedBox(width: 12.0),
          _buildStyleItemContent(),
        ],
      ),
    );
  }

  Expanded _buildStyleItemContent() {
    String styleId = BaseUtils.getKeyData(this.styleItem, 'styleId').toString();
    String styleName = BaseUtils.getKeyData(this.styleItem, 'styleName').toString();
    String sizeName = BaseUtils.getKeyData(this.styleItem, 'sizeName').toString();
    String colorName = BaseUtils.getKeyData(this.styleItem, 'colorName').toString();
    String accNums = BaseUtils.getKeyData(this.styleItem, 'accNums').toString();
    String accDiscount = BaseUtils.getKeyData(this.styleItem, 'accDiscount').toString();
    String accSprice = BaseUtils.getKeyData(this.styleItem, 'accSprice').toString();
    String accLprice = BaseUtils.getKeyData(this.styleItem, 'accLprice').toString();
    return Expanded(
      child: Container(
        child: Column(
          mainAxisAlignment: MainAxisAlignment.center,
          crossAxisAlignment: CrossAxisAlignment.start,
          mainAxisSize: MainAxisSize.min,
          children: [
            Text(styleId),
            SizedBox(height: 4),
            DefaultTextStyle(
              style: TextStyle(color: Color(0xFF868686), fontSize: 12),
              child: Row(
                mainAxisAlignment: MainAxisAlignment.spaceBetween,
                children: [
                  Flexible(
                    child: Column(
                      crossAxisAlignment: CrossAxisAlignment.start,
                      mainAxisSize: MainAxisSize.min,
                      children: [
                        Text(styleName, softWrap: false, maxLines: 1, overflow: TextOverflow.ellipsis),
                        SizedBox(height: 4),
                        Text('$colorName  $sizeName', softWrap: false, maxLines: 1, overflow: TextOverflow.ellipsis),
                        SizedBox(height: 4),
                        Text('零售价：¥$accLprice', softWrap: false, maxLines: 1, overflow: TextOverflow.ellipsis),
                      ],
                    ),
                  ),
                  Flexible(
                    child: Column(
                      mainAxisSize: MainAxisSize.min,
                      crossAxisAlignment: CrossAxisAlignment.start,
                      children: [
                        Text('数量：$accNums', softWrap: false, maxLines: 1, overflow: TextOverflow.ellipsis),
                        SizedBox(height: 4),
                        Text('折扣：$accDiscount', softWrap: false, maxLines: 1, overflow: TextOverflow.ellipsis),
                        SizedBox(height: 4),
                        Text('结算价：$accSprice', softWrap: false, maxLines: 1, overflow: TextOverflow.ellipsis),
                      ],
                    ),
                  ),
                ],
              ),
            ),
          ],
        ),
      ),
    );
  }
}
